package com.a214.yxz.yuejian013.Activity;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.Toast;

import com.a214.yxz.yuejian013.JavaBean.StringBean;
import com.a214.yxz.yuejian013.Listener.UserListener;
import com.a214.yxz.yuejian013.Model.UserModel;
import com.a214.yxz.yuejian013.R;
public class RegisterActivity extends AppCompatActivity implements View.OnClickListener, UserListener {
    public Button btn_register;
    public Button login;
    public EditText phoneNumber;
    public EditText passWord;
    String phone;
    String pwd;
    private ImageView reg_return;

    /**
     * ATTENTION: This was auto-generated to implement the App Indexing API.
     * See https://g.co/AppIndexing/AndroidStudio for more information.
     */


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.register);
        phoneNumber = (EditText) findViewById(R.id.phoneNumber);
        passWord = (EditText) findViewById(R.id.pwd);
        btn_register = (Button) findViewById(R.id.btn_register);
        reg_return= (ImageView) findViewById(R.id.reg_return);
        btn_register.setOnClickListener(this);
        reg_return.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.btn_register:
                phone = phoneNumber.getText().toString();
                pwd = passWord.getText().toString();
                UserModel usermodel = new UserModel();
                usermodel.getRegister(phone, pwd, this);
                break;
            case R.id.reg_return:
                finish();
                break;
        }
    }

    //这个方法是在Model中调用的
    @Override
    public void onResponse(StringBean stringBean) {
        Toast.makeText(this, "注册成功!", Toast.LENGTH_SHORT).show();
    }


    @Override
    public void onFail(String msg) {
        Toast.makeText(this, "" + msg, Toast.LENGTH_SHORT).show();
    }

}
